export default {
    install(Vue)  {

        // 时间格式转换
        Vue.prototype.formatDate = function (row, column) {
        let data = row[column.property]
        if (data == null) {
            return '';
        }
        let dt = new Date(data)
        let yyyy = dt.getFullYear()
        let MM = (dt.getMonth() + 1).toString().padStart(2, '0')
        let dd = dt.getDate().toString().padStart(2, '0')
        let h = dt.getHours().toString().padStart(2, '0')
        let m = dt.getMinutes().toString().padStart(2, '0')
        let s = dt.getSeconds().toString().padStart(2, '0')
        return yyyy + '-' + MM + '-' + dd + ' ' + h + ':' + m + ':' + s
        }

        // 任务状态转换
        Vue.prototype.formatTaskState = function (row, column) {
            let taskState = row[column.property]
            if (taskState == null || taskState == undefined || taskState =='') {
                return '';
            }

            if (taskState === '01' || taskState === '02') {
                return '待处理';
            } else if (taskState === '03') {
                return '已处理';
            } else if (taskState === '04') {
                return '已退回';
            }  else if (taskState === '05'){
                return '已关闭';
            } else if(taskState === '06'){
                return '提交上级';
            } else {
                return '';
            }  
        }

        // 特殊任务状态转换
        Vue.prototype.formatSpecTaskState = function (row, column) {
            let taskState = row[column.property]
            if (taskState == null || taskState == undefined || taskState =='') {
                return '';
            }

            if (taskState === '01' || taskState === '02') {
                return '待处理';
            } else if (taskState === '03') {
                return '已处理';
            }  else if (taskState === '05' || taskState === '04'){
                return '已退回';
            } else if(taskState === '06'){
                return '提交上级';
            } else {
                return '';
            }  
        }

        // 任务类型转换
        Vue.prototype.formatTaskType = function (row, column) {
            let taskType = row[column.property]
            if (taskType == null || taskType == undefined || taskType =='') {
                return '';
            }
        
            if (taskType === 'case_main') {
                return '案件登记';
            } else if (taskType === 'cancel_audit') {
                return '注销审核';
            } else if (taskType === 'survey') {
                return '调查处理';
            }  else if (taskType === 'survey_audit') {
                return '调查审核';
            }  else if (taskType === 'settle_audit') {
                return '结算审核';
            }  else if (taskType === 'recase') {
                return '重开处理';
            }  else if (taskType === 'recase_audit') {
                return '重开审核';
            }  else if (taskType === 'refund_ticket') {
                return '退票处理';
            }  else if (taskType === 'refund_ticket_audit') {
                return '退票审核';        
            }  else {
                return '核赔';
            }   
        }

        // 支付状态转换
        Vue.prototype.formatPayState = function (row, column) {
            let payState = row[column.property]
            if (payState == null || payState == undefined || payState =='') {
                return '';
            }
            if (payState === '01') {
                return '待支付';
            } else if(payState === '02'){
                return '已支付';
            }  else {
                return '已退回';
            }   
        }

        // 打印结算类型转换
        Vue.prototype.formatPrintType = function (row, column) {
            
            let printType = row[column.property]
            if (printType == null || printType == undefined || printType =='') {
                return '';
            }
            if (printType === '1') {
                return '个人';
            } else {
                return '企业';
            }   
        }
        
        // 转换调查原因
        Vue.prototype.formatSurveyReason = function (row, column) {
            let surveyReason = row[column.property]
            if (surveyReason == null || surveyReason == undefined || surveyReason =='') {
                return '';
            }
            if (surveyReason === '1') {
                return '频繁报销'
            } else if (surveyReason === '2') {
                return '异地就医'
            } else if (surveyReason === '9') {
                return '其它'
            }  
        }

        // 银行对公对私
        Vue.prototype.formatBankToPubPri = function (row, column) {
            let bankToPubPri = row[column.property]
            if (bankToPubPri == null || bankToPubPri == undefined || bankToPubPri =='') {
                return '';
            }
            if (bankToPubPri === '1') {
                return '对公';
            } else if(bankToPubPri === '2'){
                return '对私';
            }   
        }


        // 所有任务类型转换
        Vue.prototype.formatAllTaskType = function (row, column) {
            let taskType = row[column.property]
            if (taskType == null || taskType == undefined || taskType =='') {
                return '';
            }
        
            if (taskType === 'case_main') {
                return '案件登记';
            } else if (taskType === 'cancel_audit') {
                return '注销审核';
            } else if (taskType === 'survey') {
                return '调查处理';
            }  else if (taskType === 'survey_audit') {
                return '调查审核';
            }  else if (taskType === 'settle_audit') {
                return '结算审核';
            }  else if (taskType === 'recase') {
                return '重开处理';
            }  else if (taskType === 'recase_audit') {
                return '重开审核';
            }  else if (taskType === 'refund_ticket') {
                return '退票处理';
            }  else if (taskType === 'refund_ticket_audit') {
                return '退票审核';        
            }  else if (taskType === 'undwrt_f_one') {
                return '分公司核赔一级';        
            } else if (taskType === 'undwrt_f_two') {
                return '分公司核赔二级';        
            } else if (taskType === 'undwrt_f_three') {
                return '分公司核赔三级';        
            } else if (taskType === 'undwrt_f_four') {
                return '分公司核赔四级';        
            } else if (taskType === 'undwrt_f_five') {
                return '分公司核赔五级';        
            } else if (taskType === 'undwrt_z_one') {
                return '总公司核赔一级';        
            } else if (taskType === 'undwrt_z_two') {
                return '总公司核赔二级';        
            } else if (taskType === 'undwrt_z_three') {
                return '总公司核赔三级';        
            } else if (taskType === 'undwrt_z_four') {
                return '总公司核赔四级';        
            } else if (taskType === 'undwrt_z_five') {
                return '总公司核赔五级';        
            } else if (taskType === 'payee') {
                return '待支付';        
            }else if (taskType === 'close_case') {
                return '结案';        
            }  else {
                return '';
            }   
        }

    }
}
